package com.xnyzc.lhy.mis.controller.cmsapi.role;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.mis.entity.param.cms.OfficeParam;
import com.xnyzc.lhy.mis.entity.param.cms.RoleReceive;
import com.xnyzc.lhy.mis.service.cms.role.RoleService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 角色相关
 *
 * @Author: wangshuo
 * @Date: 2019-08-14 14:11
 */
@RestController
@RequestMapping("/cmsapi/roleRewrite")
public class RoleController {

    @Autowired
    private RoleService roleService;

    /**
     * 获取角色列表数据。
     *
     * @return
     */
    @ApiOperation(value = "获取角色列表数据", notes = "获取角色列表数据")
    @GetMapping(value = "/getRoleListRewrite")
    public Rv getRoleList(
    ) {
        return Rv.wrap(roleService.getRoleList());
    }

    /**
     * 获取角色详情数据。
     *
     * @return
     */
    @ApiOperation(value = "获取角色详情数据", notes = "获取角色详情数据")
    @GetMapping(value = "/getRoleDetail")
    public Rv getRoleDetail(
            Long roleId,String useable
    ) {
        return Rv.wrap(roleService.getRoleDetail(roleId,useable));
    }

    /**
     * 删除角色
     *
     * @return
     */
    @ApiOperation(value = "删除角色", notes = "删除角色")
    @PostMapping(value = "/getDeleteRole")
    public Rv getDeleteRole(
            @ApiParam(name = "roleReceive", value = "接入传参") @RequestBody RoleReceive roleReceive
    ) {
        return Rv.wrap(roleService.getDeleteRole(roleReceive));
    }

    /**
     * 获取分配页面数据
     *
     * @return
     */
    @ApiOperation(value = "获取分配页面数据", notes = "获取分配页面数据")
    @GetMapping(value = "/getAssignRole")
    public Rv getAssignRole(
            Long roleId
    ) {
        return Rv.wrap(roleService.getAssignRole(roleId));
    }

    /**
     * 从角色中移除用户
     *
     * @return
     */
    @ApiOperation(value = "从角色中移除用户", notes = "从角色中移除用户")
    @PostMapping(value = "/getOutRole")
    public Rv getOutRole(
            @ApiParam(name = "roleReceive", value = "接入传参") @RequestBody RoleReceive myRoleReceive
    ) {
        return Rv.wrap(roleService.getOutRole(myRoleReceive));
    }

    /**
     * 角色分配列表
     *
     * @return
     */
    @ApiOperation(value = "角色分配列表", notes = "角色分配列表")
    @GetMapping(value = "/getUserRole")
    public Rv getUserRole(
            Long roleId
    ) {
        return Rv.wrap(roleService.getUserRole(roleId));
    }

    /**
     * 点击机构获取人员
     *
     * @return
     */
    @ApiOperation(value = "点击机构获取人员", notes = "点击机构获取人员")
    @GetMapping(value = "/getRoleInUser")
    public Rv getRoleInUser(
            Long officeId
    ) {
        return Rv.wrap(roleService.getRoleInUser(officeId));
    }


}
